package com.synchrodata.main;


import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

import com.synchrodata.job.SynchroDataJob;
import com.synchrodata.util.PropertiesUtil;

public class SynchroDataMain {

	public static void main(String[] args) {

		//系统执行周期(秒)
		int executeTime =  PropertiesUtil.getPropertyInt("sys.executeTime");
		//创建1个定时线程池。
		ScheduledExecutorService service =  Executors.newScheduledThreadPool(100);
		//每隔 execute_time 秒，执行1次。
		SynchroDataJob synchroDataJob = new SynchroDataJob();
		service.scheduleAtFixedRate(new Runnable(){
			@Override
            public void run() {
                synchroDataJob.run();
            }
        }, 0,executeTime, TimeUnit.SECONDS);

	/*	service.scheduleWithFixedDelay(new Runnable() {
			@Override
			public void run() {
				try {
					synchroDataJob.run();
				}catch (Exception e){
					e.printStackTrace();
				}

			}
		},5, 1, TimeUnit.SECONDS);*/


	/*		ThreadPoolExecutor tpe = ((ThreadPoolExecutor) service);
	while (true) {

			//当前排队线程数
			int queueSize = tpe.getQueue().size();
			System.out.println("当前排队线程数：" + queueSize);
			if (queueSize > 3) {
				System.out.println("当前程序执行过慢,排队线程: " + queueSize + ".请注意排查原因!");
			}

			//当前活动线程数
			int activeCount = tpe.getActiveCount();
			System.out.println("当前活动线程数："+ activeCount);

			//执行完成线程数
			long completedTaskCount = tpe.getCompletedTaskCount();
			System.out.println("执行完成线程数："+ completedTaskCount);

			//总线程数
			long taskCount = tpe.getTaskCount();
			System.out.println("总线程数："+ taskCount);

			try {
				//休眠3秒
				Thread.sleep(2000);
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
		}*/
	}

}
